<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/plateform/include/common-base.jsp"%>
  <title>在线流程设计器</title>
  <link href="${ctx}/common/plateform/plugins/jQueryUI/jquery-ui.css" rel="stylesheet">
  <script src="${ctx}/common/plateform/plugins/jQueryUI/jquery-ui.min.js"></script>
  <link href="${ctx}/common/plateform/plugins/jvisio/jvisio.css" rel="stylesheet">
  <script>
      var clickMenu = "audit-jvisio";
      var thisSysEname = "${param.sysEname}";
  </script>
</head>
  <style>
      .content-wrapper {
          margin-left: 0px;
      }
  </style>
<!-- Part 一、 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">


  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content" style="padding:1px;">
      <div class="row">

          <div id="diagramContainer-left" class="col-sm-1">
              <div class="box box-solid box-info">
                  <div class="box-header with-border">
                      <h3 class="box-title">
<%--                          <i class="fa fa-list-ul"></i> 节点选择--%>
                      </h3>
                          <form class="hidden" id="searchForm_ruledata" action="javascript:void(0)">
                              <input type="hidden" name="pageName" value="audit-rule-list"/>
                              <input type="hidden" name="formName" value="searchForm"/>
                              <input type="hidden" name="sysAuditRule.auditType" value="${param.flowNo}"/>
                              <input type="hidden" name="orderBy" value="sysAuditRule.num asc"/>
                          </form>
                      <div class="box-tools pull-right">
                          <button type="button" class="btn btn-box-tool" id="btn-clean-jvisio"><i class="fa fa-trash-o"></i></button>
                          <button type="button" class="btn btn-box-tool" id="btn-init-jvisio"><i class="fa fa-database"></i></button>
                      </div>
                  </div>
                  <div class="box-body jnode-minh">
                      <div class="form-group">
                          <ul class="f8 fx8">
                              <li>节点拖拽右侧</li>
                              <li>节点四周连线</li>
                              <li>左击参数设置</li>
                              <li>右击删除元素</li>
                              <li>最后保存设置</li>
                              <!--
                                <li>① 选择节点类型可拖拽设计</li>
                              <li>② 节点四周可拖拽画连接线</li>
                              <li>③ 左击节点及线上文字设置</li>
                              <li>④ 右击节点及线可删除元素</li>
                              <li>⑤ 最后保存修改参数设置</li>
                                -->
                          </ul>
                      </div>
                      <div class="form-group">
                          <div  class="jnodetios">
                              <div class="jnode-box jnode-round bdc-success"
                                   data-jnode-type="start" data-jnode-last="00" data-jnode-next="" data-jnode-class="jnode-radius bdc-success"><span>开始</span></div>
                          </div>

                          <div  class="jnodetios">
                              <div class="jnode-box jnode-rectangle bdc-primary"
                                   data-jnode-type="task" data-jnode-last="" data-jnode-next="" data-jnode-class="jnode-task bdc-primary"><span>任务</span></div>
                          </div>

                          <div  class="jnodetios">
                              <div class="jnode-box jnode-diamond bdc-warning"
                                   data-jnode-type="judge" data-jnode-last="" data-jnode-next="" data-jnode-class="jnode-diamond jnode-judge bdc-warning"><span><i class="fa fa-plus-circle"></i></span></div>
                          </div>

                          <div  class="jnodetios">
                              <div class="jnode-box jnode-round bdc-danger"
                                   data-jnode-type="end" data-jnode-last="" data-jnode-next="00" data-jnode-class="jnode-radius bdc-danger"><span>结束</span></div>
                          </div>
                      </div>
                  </div>
              </div>
          </div>

          <div id="diagramContainer-main" class="col-sm-11 jnode-main bg-info">
              <div>Design Area</div>
          </div>

          <!-- 定义目标节点的模板 -->
          <script type="text/x-mustache" id="jnode-template">
            <div class="jnode-panel" id="{{id}}" style="top:{{x}}px;left:{{y}}px">
                <div class="jnode-box {{jnodeClass}}" jnode-type="{{jnodeType}}" jnode-num="{{jnodeNum}}" jnode-code="{{jnodeCode}}" jnode-last="{{jnodeLast}}" jnode-next="{{jnodeNext}}" jnode-rule="{{jnodeRule}}" rule-id="{{ruleId}}"><span>{{{jnodeName}}}</span></div>
            </div>
          </script>


          <div id="diagramContainer-tools-box" class="jnode-control" >
              <div class="box box-solid box-info control-toggle-body">
                  <div class="box-header">
                      <h3 class="box-title" id="title_header"><i class="fa fa-cog"></i> 参数设置<span id="jnode-control-title-span" class="f14"></span></h3>
                      <div class="box-tools pull-right hidden">
                          <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                          </button>
                      </div>
                  </div>
                  <div class="box-body" id="diagramContainer-control">
                      <div class="panel-group" id="accordion">
                          <div class="panel panel-default">
                              <div class="panel-heading">
                                  <h4 class="panel-title jnode-control-title">
                                      <a data-toggle="collapse" data-parent="#accordion" href="#collapse_body_1">
                                          <i class="fa fa-tags"></i> 基本设置
                                      </a>
                                      <a data-toggle="collapse" data-parent="#accordion" href="#collapse_body_1" class="pull-right"><i class="fa fa-minus"></i></a>
                                  </h4>
                              </div>
                              <div id="collapse_body_1" class="panel-collapse collapse in">
                                  <div class="panel-body jnode-control-item" style="overflow:auto;">
                                      <form class="form-horizontal" id="control_body_form1" action="javascript:void(0)">
                                          <input type="hidden" name="pageName" value="audit-rule-list"/>
                                          <input type="hidden" name="formName" value="addForm"/>
                                          <input type="hidden" name="sysAuditRule.sysName" value="${param.sysEname}"/>
                                          <input type="hidden"  class="clean" name="sysAuditRule.ifCustom" value="F"/>
                                          <input type="hidden" name="sysAuditRule.auditType" class="form-control" value="${param.flowNo}"/>
                                          <input type="hidden" name="sysAuditRule.ifStart" class="form-control clean" jnode-name="ifStart" value="F"/>
                                          <input type="hidden" name="sysAuditRule.nodeConfig" class="form-control clean" jnode-name="jnodeConfig" value=""/>
                                          <input type="hidden" name="sysAuditRule.num" class="form-control clean" jnode-name="jnodeNum" maxlength="20"/>
                                          <input type="hidden" name="sysAuditRule.w_ruleId" class="form-control clean" jnode-name="ruleId" value=""/>
                                          <div class="form-group hidden">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">上一节点</span>
                                                  <input name="sysAuditRule.last" readonly="readonly" type="text" class="form-control clean" jnode-name="jnodeLast" placeholder="连线节点自动填充" maxlength="20"/>
                                              </div>
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">下一节点</span>
                                                  <input name="sysAuditRule.next" readonly="readonly" type="text" class="form-control clean" jnode-name="jnodeNext" placeholder="连线节点自动填充" maxlength="20"/>
                                              </div>
                                          </div>

                                          <div class="form-group hidden">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">节点类型</span>
                                                  <select name="sysAuditRule.nodeType" class="form-control clean" readonly="readonly" jnode-name="jnodeType">
                                                      <option value="">-请选择-</option>
                                                      <option value="start">开始节点</option>
                                                      <option value="task">任务节点</option>
                                                      <option value="judge">判断条件节点</option>
                                                      <option value="end">结束节点</option>
                                                  </select>
                                              </div>
                                          </div>
                                          <div class="form-group">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">节点编号</span>
                                                  <input name="sysAuditRule.taskNo" readonly="readonly" type="text" class="form-control clean" jnode-name="jnodeCode" placeholder="选中节点自动填充" maxlength="30"/>
                                              </div>
                                          </div>
                                          <div class="form-group">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">节点名称</span>
                                                  <input name="sysAuditRule.taskName" type="text" class="form-control clean" jnode-name="jnodeName" placeholder="选中节点自动填充" maxlength="8"/>
                                              </div>
                                          </div>
                                          <div class="form-group item-task">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">选择角色</span>
                                                  <select id="control_body_form1_actroles" onchange="getUserStr(this.value);" class="form-control clean" >
                                                      <option value="">-请选择角色-</option>
                                                  </select>
                                              </div>
                                          </div>
                                          <div class="form-group item-task">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">审核人员</span>
                                                  <input type="text" class="form-control clean" readonly="readonly" name="sysAuditRule.checkUser" placeholder="必填项，请先选择角色" maxlength="100"/>
                                              </div>
                                          </div>
                                          <div class="form-group item-task">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">审核地址</span>
                                                  <input type="text" class="form-control" name="sysAuditRule.toUrl" placeholder="必填项" maxlength="50" value="/rule/audit/common-audit"/>
                                              </div>
                                          </div>
                                          <div class="form-group item-task">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">引用地址</span>
                                                  <input type="text" class="form-control clean" name="sysAuditRule.linkUrl" placeholder="必填项，如/user/user-view" maxlength="100"/>
                                              </div>
                                          </div>
                                          <div class="form-group item-judge-line hidden">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">线条名称</span>
                                                  <input name="sysAuditRule.jnodeExprName" type="text" class="form-control clean" jnode-name="jnodeExprName" placeholder="必填项" maxlength="10"/>
                                              </div>
                                          </div>
                                          <div class="form-group item-judge-line hidden">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">表达式值</span>
                                                  <input name="sysAuditRule.jnodeExprVal" type="text" class="form-control clean" jnode-name="jnodeExprVal" placeholder="必填项" maxlength="30"/>
                                              </div>
                                          </div>
                                      </form>
                                  </div>
                                  <div class="panel-footer">
                                      <button type="button" class="btn btn-default btn-xs btn-block" btn-save-control="control_body_form1" disabled="disabled"><i class="fa fa-save"></i> 保存修改设置</button>
                                  </div>
                              </div>
                          </div>
                          <div class="panel panel-default">
                              <div class="panel-heading">
                                  <h4 class="panel-title jnode-control-title">
                                      <a data-toggle="collapse" data-parent="#accordion" href="#collapse_body_2">
                                          <i class="fa fa-link"></i> 高级设置
                                      </a>
                                      <a data-toggle="collapse" data-parent="#accordion" href="#collapse_body_2" class="pull-right"><i class="fa fa-minus"></i></a>
                                  </h4>
                              </div>
                              <div id="collapse_body_2" class="panel-collapse collapse">
                                  <div class="panel-body jnode-control-item">
                                      <form class="form-horizontal" id="control_body_form2" action="javascript:void(0)">
                                          <input type="hidden" name="pageName" value="audit-rule-list"/>
                                          <input type="hidden" name="formName" value="editForm"/>
                                          <input type="hidden" name="sysAuditRule.w_ruleId" class="clean" jnode-name="ruleId" value=""/>
                                          <div class="form-group">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon"><a href="javascript:;" class="btn btn-primary btn-xs" onclick="toOpenIus('control_body_form2')">快速选择</a></span>
                                                  <input type="text" class="form-control clean" readonly="readonly" name="sysAuditRule.tableName" placeholder="请先选择对象" maxlength="50"/>
                                              </div>
                                          </div>
                                          <div class="form-group">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">主键属性名</span>
                                                  <input type="text" class="form-control clean" name="sysAuditRule.colName" placeholder="必填项" maxlength="50"/>
                                              </div>
                                          </div>
                                          <div class="form-group">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">pageName</span>
                                                  <input type="text" class="form-control clean" readonly="readonly" name="sysAuditRule.pageName" placeholder="选择后自动填充" maxlength="100"/>
                                              </div>
                                          </div>
                                          <div class="form-group">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">formName</span>
                                                  <input type="text" class="form-control clean" readonly="readonly" name="sysAuditRule.formName" placeholder="选择后自动填充" maxlength="100"/>
                                              </div>
                                          </div>
                                          <div class="form-group">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">通过后修改</span>
                                                  <input type="text" class="form-control clean" name="sysAuditRule.colNameY" placeholder="必填项" maxlength="300"/>
                                              </div>
                                          </div>
                                          <div class="form-group">
                                              <div class="input-group input-group-sm">
                                                  <span class="input-group-addon">不通过修改</span>
                                                  <input type="text" class="form-control clean" name="sysAuditRule.colNameN" placeholder="必填项" maxlength="300"/>
                                              </div>
                                          </div>
                                      </form>
                                  </div>
                                  <div class="panel-footer">
                                      <button type="button" class="btn btn-default btn-xs btn-block" btn-save-control="control_body_form2" disabled="disabled"><i class="fa fa-save"></i> 保存修改设置</button>
                                  </div>
                              </div>
                          </div>
                      </div>

                  </div>
              </div>
              <div class="jnode-control-toggle">
                  <i class="fa fa-angle-right"></i>
              </div>
          </div>

          <div class="col-sm-12 diagramContainer-console" style="font-size:10px;color:#999;">
              <div class="col-sm-12"><div class="col-sm-12 console-msg"></div></div>
          </div>
      </div>

        <script src="${ctx}/common/plateform/base/layer/extend/layer.ext.js"></script>

        <script src="${ctx}/common/plateform/plugins/jvisio/lib/uuid.min.js"></script>
        <script src="${ctx}/common/plateform/plugins/jvisio/lib/mustache.min.js"></script>
        <script src="${ctx}/common/plateform/plugins/jvisio/lib/jquery.jsPlumb-1.7.2.js"></script>
        <script src="${ctx}/common/plateform/plugins/jvisio/jvisio-config.js"></script>
        <script src="${ctx}/common/plateform/plugins/jvisio/jvisio-design.js"></script>

        <!-- Part 二、以下是template模板定义的模块区域 -->

        <!-- Part 二、 以下是js模块区域 -->
<script>
//暂无

$(function () {
    getAuditActRoles();
});
//给右侧工具条追加可隐藏操作的工具条
$(".jnode-control-toggle").click(function(){
    var ifa_obj = $(this).find("i");
    if (ifa_obj.hasClass('fa-angle-right')) {
        $(".jnode-control").animate({width:'0'},function () {
            $(".control-toggle-body").hide();
        });
        ifa_obj.removeClass("fa-angle-right").addClass("fa-angle-left");
    }else{
        $(".control-toggle-body").show();
        $(".jnode-control").animate({width:'240'});
        ifa_obj.removeClass("fa-angle-left").addClass("fa-angle-right");
    }
});

    //加载当前登录用户orgId所拥有的角色
    function getAuditActRoles() {
        var actRoleSelectObj = $("#control_body_form1_actroles");
        var index_load = layer.load(1, {shade: false});
        $.ajax({type:'get', url:ctx+'/trans/list/?doCode=actRoles',dataType:'json',
            success: function(myData){
                console.log("get actRoles",myData);
                layer.close(index_load);
                if(myData.flag='T'){
                    actRoleSelectObj.empty();
                    actRoleSelectObj.append("<option value=''>-请选择角色-</option>");
                    $.each(myData.rows, function(index, content){
                        actRoleSelectObj.append("<option value='"+content.roleId+"'>"+content.roleCname+"-["+content.roleRemark+"]</option>");
                    });
                }else{
                    layer.msg(myData.msg);
                }
            }
        });
    }

    //加载对应角色所拥有的用户人员
    function getUserStr(value){
        var checkUserObj = $("#control_body_form1").find("input[name='sysAuditRule.checkUser']");
        checkUserObj.val("");
        if(!strUtil.isNull(value)){
            var index_load = layer.load(1, {shade: false});
            $.ajax({type:'get', url:ctx+'/trans/list/?doCode=userList',data:{"roleId":value},dataType:'json',
                success: function(myData){
                    layer.close(index_load);
                    var users= "";
                    if(myData.flag=='T'){
                        for (var i = 0;i<myData.total;i++){
                            users = users==""?myData.rows[i].userEname : users+","+myData.rows[i].userEname
                        }
                        checkUserObj.val(users);
                    }else{
                        layer.msg("所选角色下暂未设置对应人员！");
                    }
                }
            });
        }
    }

    //快速选择IUS参数
var openIusWin = null,pageNameTempObj,formNameTempObj,objNameTempObj;
function toOpenIus(formId){
    var divObj = $("#"+formId);
    pageNameTempObj = divObj.find("input[name='sysAuditRule.pageName']");
    formNameTempObj = divObj.find("input[name='sysAuditRule.formName']");
    objNameTempObj = divObj.find("input[name='sysAuditRule.tableName']");
    var pageName = pageNameTempObj.val();
    var thisObjName = strUtil.doNull(objNameTempObj.val(),"");
    pageName=strUtil.doNull(pageName,"");
    var formName = strUtil.doNull(formNameTempObj.val(),"");
    openIusWin = layer.open({
        type: 2,
        title:"IUS参数设置",
        shadeClose: false,
        shade: 0.6,
        area: ['1100px', '600px'],
        offset: '10px',
        content: ctx+"/sendPage/plateform/admin/project/sysParamManager-list-sample?sysEname="+thisSysEname+"&objName="+thisObjName+"&pageName="+pageName+"&formName="+formName //iframe的url
    });
}


//选中IUS后回调方法
function preIusCallBack(ob){
    layer.close(openIusWin);
    var pageName = $(ob).attr("pagename");
    var formName = $(ob).attr("formname");
    var infoId = $(ob).attr("infoid");
    var modelTypes = $(ob).attr("modeltypes");
    pageNameTempObj.val(pageName);
    formNameTempObj.val(formName);
    var modelObjName=modelTypes;
    if(modelTypes.indexOf(",")>-1){
        modelObjName = modelTypes.split(",")[0];
    }
    if(modelObjName.indexOf("_")>-1){
        objNameTempObj.val(modelObjName.split("_")[1]);//objName
    }
}


</script>

</section>
<!-- Main end -->   
</div>
</div>
<!-- /.content-wrapper -->
<!-- foot start -->
<!-- foot start -->
</body>
</html>




